package com.wyzz.hr.action;

import java.util.*;

import com.wyzz.hr.base.BasePdfExport;
import com.wyzz.hr.base.wf.overtimerequest.OrWfApproverAction;
import com.wyzz.hr.bo.TemplateService;
import com.wyzz.hr.pojo.Overtimerequest;
import com.wyzz.hr.spring.SpringBeanFactory;
import com.wyzz.hr.vo.OvertimeFormBean;

public class DeptHRApproveOTAction extends OrWfApproverAction {

	public DeptHRApproveOTAction() {
		expireTiaoxiu = Integer.valueOf(0);
		templateName = "print_overtime";
	}

	public String showOT_M() throws Exception {
		if (of_Bean == null)
			of_Bean = new OvertimeFormBean();
		otr = initOfBean("modify", of_Bean, orIdUp);
		if (otr == null)
			return "error";
		else
			return "success";
	}

	public String showOT_HR() throws Exception {
		if (of_Bean == null)
			of_Bean = new OvertimeFormBean();
		otr = initOfBean("hr-modify", of_Bean, orIdUp);
		if (otr == null)
			return "error";
		else
			return "success";
	}

	public String getOrInfo() throws Exception {
		if (of_Bean == null)
			of_Bean = new OvertimeFormBean();
		otr = initOfBean("modify", of_Bean, orIdUp);
		if (otr == null)
			return "error";
		Map modal = new HashMap();
		if ("pdf".equals(resultType))
			otr.setOrReason(BasePdfExport.processWrap(otr.getOrReason(), 530,
					20, 12));
		modal.put("otr", otr);
		modal.put("of_Bean", of_Bean);
		TemplateService templateService = (TemplateService) SpringBeanFactory
				.getBean("ftlTemplateService");
		printContent = templateService.getPDFContent(templateName, modal);
		if ("pdf".equals(resultType)) {
			String fileNameWithPath = BasePdfExport.pdfExport(printContent);
			if (download(fileNameWithPath, (new StringBuilder()).append(
					"overtimeInfo_NO").append(otr.getOrNo()).append(".pdf")
					.toString()))
				return "download";
		}
		return "success";
	}

	public String getOrIdUp() {
		return orIdUp;
	}

	public void setOrIdUp(String orIdUp) {
		this.orIdUp = orIdUp;
	}

	public OvertimeFormBean getOf_Bean() {
		return of_Bean;
	}

	public void setOf_Bean(OvertimeFormBean of_Bean) {
		this.of_Bean = of_Bean;
	}

	public Overtimerequest getOtr() {
		return otr;
	}

	public void setOtr(Overtimerequest otr) {
		this.otr = otr;
	}

	public String getSrcAction() {
		return srcAction;
	}

	public void setSrcAction(String srcAction) {
		this.srcAction = srcAction;
	}

	public String getInfoMeg() {
		return infoMeg;
	}

	public void setInfoMeg(String infoMeg) {
		this.infoMeg = infoMeg;
	}

	public int getGmanager() {
		return gmanager;
	}

	public void setGmanager(int gmanager) {
		this.gmanager = gmanager;
	}

	public String getIsTiaoxiu() {
		return isTiaoxiu;
	}

	public void setIsTiaoxiu(String isTiaoxiu) {
		this.isTiaoxiu = isTiaoxiu;
	}

	public String getTiaoXiuTime() {
		return tiaoXiuTime;
	}

	public void setTiaoXiuTime(String tiaoXiuTime) {
		this.tiaoXiuTime = tiaoXiuTime;
	}

	public Date getOtTiaoxiuExpire() {
		return otTiaoxiuExpire;
	}

	public void setOtTiaoxiuExpire(Date otTiaoxiuExpire) {
		this.otTiaoxiuExpire = otTiaoxiuExpire;
	}

	public Integer getExpireTiaoxiu() {
		return expireTiaoxiu;
	}

	public void setExpireTiaoxiu(Integer expireTiaoxiu) {
		this.expireTiaoxiu = expireTiaoxiu;
	}

	public String getResultType() {
		return resultType;
	}

	public void setResultType(String resultType) {
		this.resultType = resultType;
	}

	public String getPrintContent() {
		return printContent;
	}

	public void setPrintContent(String printContent) {
		this.printContent = printContent;
	}

	private static final long serialVersionUID = 1L;
	private OvertimeFormBean of_Bean;
	private Overtimerequest otr;
	private String orIdUp;
	private int gmanager;
	private String srcAction;
	private String infoMeg;
	private String isTiaoxiu;
	private String tiaoXiuTime;
	private Date otTiaoxiuExpire;
	private Integer expireTiaoxiu;
	private String resultType;
	private String templateName;
	private String printContent;
}
